

import React from 'react'
import { Upload, message, Button,Form, Input, Checkbox } from 'antd';
import { UploadOutlined } from '@ant-design/icons';

import "./CreateVideo.scss"
import { BASE_ADDR } from '../../apis/http';
import { httpAddVideo } from '../../apis';
import { useSelector } from 'react-redux';




export default function UploadVideo() {
  const user = useSelector(state=>state.user);
  const onFinish = async (values: any) => {
    console.log("创建一个新的视频条目: ",values);
    values.time = new Date().getTime();
    values.userId = user.userId;
    let res = await httpAddVideo(values);
    if(res) {
      message.success("创建成功~");
    } else {
      message.error("创建失败!");
    }
  };
  return (
    <div className='UploadVideo-container'>
      <Form
        name="basic"
        labelCol={{ span: 10 }}
        wrapperCol={{ span: 30 }}
        initialValues={{ remember: true }}
        onFinish={onFinish}
        autoComplete="off"
      >
        <Form.Item
          label="视频标题"
          name="videoName"
          rules={[{ required: true, message: '请输入你的视频标题' }]}
        >
          <Input />
        </Form.Item>

        <Form.Item
          label="视频封面"
          name="coverURL"
        >
          <Input />
        </Form.Item>
        <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
          <Button type="primary" htmlType="submit">
            创建
          </Button>
        </Form.Item>
      </Form>

    </div>
  )
}
